Skip to main content

Other CI Providers

Any CI system that can run a shell script can send test results to BuildPulse. This page covers Jenkins, GitLab CI, Buildkite, Azure Pipelines, Google Cloud Build, Semaphore, Travis CI and anything else that is not GitHub Actions or Bitbucket Pipelines.

The upload has two HTTP calls: ask BuildPulse for a signed upload URL, then send a .tar.gz of your JUnit XML files to it. It needs git, curl and tar, and an API token.

If you'd like help at any step, please get in touch.

1. Create an API key.

In BuildPulse, open Organization Settings, then API Keys, and click Create API Key. The key starts with bp_ and is shown once. Store it in your CI's secret store so that it reaches the job as the BUILDPULSE_API_TOKEN environment variable.

2. Copy the upload script for your repository.

In BuildPulse, open the repository and go to its Setup tab. Under "Wire BuildPulse into your CI pipeline", pick the CI system that runs your tests and your test framework. The page shows a script with your repository ID already filled in, and for Jenkins, GitLab CI, Buildkite, Azure Pipelines and Google Cloud Build it also fills in that system's build variables. Use that script where you can: it is the version maintained with the product.

The repository has to exist in BuildPulse first. For a repository hosted on GitHub, install the BuildPulse GitHub App on it, even if another CI system runs its tests.

For reference, this is the script for a CI system that is not on the list. Replace <your-repository-id> with the ID shown on the Setup tab, and set RESULTS_GLOB to where your test framework writes its JUnit XML.

set -euo pipefail

REPO_ID="<your-repository-id>"
RESULTS_GLOB="junit.xml"

# Assemble the archive.
rm -rf _bp && mkdir -p _bp/test-results _bp/coverage
cp $RESULTS_GLOB _bp/test-results/ 2>/dev/null || cp -r $RESULTS_GLOB/. _bp/test-results/

cat > _bp/buildpulse.yml <<YML
version: "1.0"
source: buildpulse-action
timestamp: $(date -u +%Y-%m-%dT%H:%M:%S.000Z)
git:
commit: $(git rev-parse HEAD)
message: "$(git log -1 --pretty=%s | sed 's/"/\\"/g')"
branch: $(git rev-parse --abbrev-ref HEAD)
tree: $(git rev-parse 'HEAD^{tree}')
ci:
# Optional but recommended: point these at your CI's environment variables.
# They make a run clickable and group reruns of the same build together.
provider: custom
build_id: "${CI_BUILD_ID:-}"
build_url: "${CI_BUILD_URL:-}"
YML

tar -C _bp -czf buildpulse.tar.gz buildpulse.yml test-results coverage

# 1. Ask for a signed upload URL (expires in 5 minutes).
RESP="$(curl -fsS -X POST https://buildpulse.io/api/test-results/upload-url \
-H "Authorization: Bearer $BUILDPULSE_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"repositoryId\":\"$REPO_ID\"}")"

URL="$(printf '%s' "$RESP" | sed -n 's/.*"uploadUrl":"\([^"]*\)".*/\1/p')"
[ -n "$URL" ] || { echo "upload-url failed: $RESP"; exit 1; }

# 2. Upload the archive.
curl -fsS -X PUT "$URL" -H "Content-Type: application/gzip" --data-binary @buildpulse.tar.gz

echo "BuildPulse upload complete."

3. Run it after your tests, including when they fail.

Failing runs are where flaky tests show up, so configure the step to run even when the test command exits non-zero.

Notes:

  • The job needs a git checkout. The tree value is the git tree SHA, which BuildPulse uses to tell that two results came from the same code.
  • To upload coverage, copy an LCOV file (.lcov or .info) or a Cobertura XML file with coverage in its name into _bp/coverage/ before the tar step.
  • To tag the upload, add a top-level tags: list to buildpulse.yml. See Tags.

Within a few minutes of the first upload, the repository's Test Runs tab shows the run.

Using the test-reporter binary, the CircleCI orb or the Bitbucket pipe?

Those integrations authenticate with an access key ID and secret access key plus numeric account and repository IDs. New accounts are not issued access keys, so new setups should follow the steps above. If you already run one of them and have questions about moving, email support@buildpulse.io.